class Const(object):

    def __init__(self):
        self.login_pc = {'token': '', 'user': ''}
        self.login_mall = {'token': '', 'user': ''}
        # 销售助手
        self.login_xszs = {'token': '', 'user': ''}
        self.login_app = {'token': '', 'user': ''}
        self.login_c = {'token': '', 'user': ''}

    def set_pc_info(self, res):
        self.login_pc['token'] = res['data']['token']
        self.login_pc['user'] = res['data']
        self.login_c = self.login_pc

    def set_app_info(self, res):
        self.login_app['token'] = res['data']['token']
        self.login_app['user'] = res['data']
        self.login_c = self.login_app

    def set_pc_mall_info(self, res):
        self.login_mall['token'] = res['data']['token']
        self.login_mall['user'] = res['data']
        self.login_c = self.login_mall

    def set_xszs_info(self, res):
        self.login_xszs['token'] = res['data']['token']
        self.login_xszs['user'] = res['data']
        self.login_c = self.login_xszs

    def get_token(self):
        return self.login_c['token']

    def get_user(self):
        return self.login_c['user']

    def change_pc(self):
        self.login_c = self.login_pc

    def change_app(self):
        self.login_c = self.login_app


class BaseInfo(object):
    active = "dev"
    set_header = False
    login = Const()
    __url_obj = {
        "dev": {
            "sys": "http://10.129.83.242"
        }, "test": {
            "sys": "http://10.129.83.130"
        }, "backup": {
            "sys": "http://10.129.83.213"
        }
    }

    __mq_config_obj = {
        "dev": {'host': '10.129.83.213', 'vhost': '/pre_test'},
        "test": {'host': '10.129.83.213', 'vhost': '/test'},
        "backup": {'host': '10.129.83.213', 'vhost': '/backup'},
    }

    @staticmethod
    def get_sys_base_url():
        return BaseInfo.__url_obj[BaseInfo.active]['sys']

    @staticmethod
    def get_mq_config():
        return BaseInfo.__mq_config_obj[BaseInfo.active]
